<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@page import="java.util.List"%>
<%@page import="java.util.*"%>
<%@page import="org.springframework.web.context.WebApplicationContext"%>
<%@page
	import="org.springframework.web.context.support.WebApplicationContextUtils"%>
<%@ page import="java.util.ArrayList"%>

<%@page import="com.yellowpage.white.ui.*"%>
<%@page import="com.yellowpage.white.ui.MenuItem"%>

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<%
	String theme = getServletContext().getInitParameter("white-theme");

	String topImageUrl = "";

	Menu menu = new XMLMenuImpl(request);

	List menuItemList = menu.getMenuItemList();
%>

<c:set var="ctx" value="${pageContext.request.contextPath}" />
<html>
	<head>
		<link rel="StyleSheet" href="${ctx}/white/common/dtree.css"
			type="text/css" />
		<script type="text/javascript" src="${ctx}/white/common/dtree.js">
</script>
	</head>
	<body>		
		<div class="dtree">
			<p>
				<a href="javascript: d.openAll();">全部展开</a> |
				<a href="javascript: d.closeAll();">全部收起</a>
			</p>
			<script type="text/javascript">
			<!--
		d = new dTree('d');
		d.add(0,-1,'OMC');
			
<%
    int seq = 1;
	for (int j = 0; j < menuItemList.size(); j++) {
		MenuItem myTopMenu = (MenuItem) menuItemList.get(j);
		List subItems = myTopMenu.getSubMenuItems();
		int parent = seq;
		
		if(myTopMenu.isVisible()){
%>
	d.add(<%=seq%>,0,'<%=myTopMenu.getName()%>','');
	<%
	    seq++;
	    
		for (int i = 0; i < subItems.size(); i++) {
				MenuItem subItem = (MenuItem) subItems.get(i);
				if(subItem.isVisible()){
				    List sub2Items = subItem.getSubMenuItems();
				    if(sub2Items != null && sub2Items.size() > 0){
				      
				      %>				      
				      d.add(<%=seq%>,<%=parent%>,'<%=subItem.getName()%>',''); 
				      <% 
				      parent = seq;
				      seq++;
				      
				      for (int n = 0; n < sub2Items.size(); n++) {
				          MenuItem sub2Item = (MenuItem) sub2Items.get(n);
				          if(sub2Item.isVisible()){
				          
				              %>
												d.add(<%=seq%>,<%=parent%>,'<%=sub2Item.getName()%>','${ctx}<%=sub2Item.getDistination()%>','','main');
											<%
				          
				              seq++;
				          }				          
				      }    
				      
				    }
				    else{   
							%>
								d.add(<%=seq%>,<%=parent%>,'<%=subItem.getName()%>','${ctx}<%=subItem.getDistination()%>','','main');
							<%
	            seq++;
	          }   
		        
		    }
		}
	%>		
<%
        }
	}
%> 		
		//d.add(<%=seq%>,0,'Recycle Bin','example01.html','','','img/trash.gif');
		document.write(d);
		//-->
	</script>
		</div>
	</body>
</html>